/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;

/**
 * <p>Project: jse2302 - Ex3
 * <p>Powered by webrx On 2023-06-19 16:34:25
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex3 {
    public static void main(String[] args) {

        //String s1 = "aab";
        //String s2 = "Aba";
        ////System.out.println("ate".equals("tea"));
        //char[] cs1 = s1.toCharArray();
        //char[] cs2 = s2.toCharArray();
        //Arrays.sort(cs1);
        //Arrays.sort(cs2);
        //System.out.println(new String(cs1).equalsIgnoreCase(new String(cs2)));
        //System.out.println(cs2);




        String str = "javajavaaapaublic java staticjava voijavad main(String[] argsjava)";
        //检查字符a出现的次数
        //char c = 'a';
        //int pos = str.indexOf(c);
        //int sum = 0;
        //while(pos!=-1){
        //    ++sum;
        //    System.out.println(pos);
        //    pos = str.indexOf('a',pos+1);
        //}
        //System.out.printf("%c字符在%s中出现：%d次%n",'a',c,sum);

        //检查字符串cs出现的次数
        String cs = "java";
        int pos = str.indexOf(cs);
        int sum = 0;
        while (pos >= 0) {
            ++sum;
            System.out.println(pos);
            pos = str.indexOf(cs, pos + 1);
        }
        System.out.printf("%c字符在%s中出现：%d次%n", 'a', cs, sum);
    }
}
